﻿using YunSpace.Core;

namespace YunSpace.Application.Messaging
{
    /// <summary>
    /// 消息发送者
    /// </summary>
    public abstract class MessageSender
    {
        public string Email { get; set; }

        public string Phone { get; set; }

        public string Content { get; set; }

        public string Title { get; set; }

        public string ReceiverId { get; set; }

        /// <summary>
        /// 发送前校验
        /// </summary>
        /// <returns></returns>
        public BeforeSendValidateState BeforeSendValidate()
        {
            return Title.IsEmpty()
                ? BeforeSendValidateState.EmptyTitle
                : (Content.IsEmpty()
                    ? BeforeSendValidateState.EmptyBody
                    : Validate());
        }

        /// <summary>
        /// 发送
        /// </summary>
        public abstract void Send();

        /// <summary>
        /// 校验
        /// </summary>
        /// <returns></returns>
        protected abstract BeforeSendValidateState Validate();
    }
}
